import { Auths } from '@/utils/types.d';
import { PageContainer } from '@ant-design/pro-layout';
import React, { useState } from 'react';
import { useModel } from 'umi';
import WechatMsgConfig from './WechatMsgConfig';

const MessageConfig: React.FC = () => {
  const [tab, setTab] = useState<string>('wechat-message');
  const { initialState } = useModel('@@initialState');
  const currUser = initialState?.currentUser;
  const auths = currUser?.auth ? new Set(currUser.auth.systemConfig || []) : new Set();
  const ifConfig = auths.has(Auths.TEMPLATE_CONFIG);

  return (
    <PageContainer
      header={{
        breadcrumb: {
          routes: [
            {
              path: '/',
              breadcrumbName: '首页',
            },
            {
              path: '/setting-config',
              breadcrumbName: '系统配置',
            },
            {
              path: '/message',
              breadcrumbName: '消息模板配置',
            },
          ],
        },
        subTitle: '消息模板配置',
      }}
      tabList={[
        { tab: '微信公众号模板消息', key: 'wechat-message' },
        // { tab: '短信模板消息', key: 'sms-message' },
      ]}
      tabActiveKey={tab}
      onTabChange={(key) => setTab(key)}
    >
      {tab === 'wechat-message' && <WechatMsgConfig ifConfig={ifConfig} />}
      {/* {tab === 'sms-message' && <SMSConfig ifConfig={ifConfig} />} */}
    </PageContainer>
  );
};
export default MessageConfig;
